package cn.u313.lymusic.utils

import android.content.Context
import android.view.View
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

class YUtils {
}
@Composable
fun Width(int: Int){
    Spacer(modifier = Modifier.width(int.dp))
}
@Composable
fun Height(int: Int){
    Spacer(modifier = Modifier.height(int.dp))
}

fun dp2px(context: Context, dp: Int): Int {
    val density = context.resources.displayMetrics.density
    return (dp * density).toInt()
}
fun View.click(block:()->Unit){
    this.setOnClickListener {
        block.invoke()
    }
}
fun View.show(){
    this.visibility = View.VISIBLE
}
fun View.hide(){
    this.visibility = View.GONE
}